#include <stdio.h>
#include <string.h>

FILE * getCipherFileFromUser()
{
	FILE * fp;
	char fname[200];
	char *ret;
	
	while(1)
	{
		//get a valid filename
		char *newline;
		do
		{
			printf("Enter the name of the file containing the Cipher Text:  ");
			ret = fgets(fname, 200, stdin);
		}
		while(ret == NULL);
		
		newline = strchr(fname, '\n');
		
		//if there is a newline replace it with a null terminator
		//if not then the path name filled the buffer
		//more likely than not the path will not be fully contained and the file will
		//not be found.  The buffer should be big enough to hold most paths.
		if(newline != NULL)
		{
			*newline = '\0';
		}
		
		if((fp = fopen((const char *)fname, "r")) != NULL)
		{
			return fp;
		}
	}
}

FILE * getVectorFileFromUser()
{
	FILE * fp;
	char fname[200];
	char *ret;
	
	while(1)
	{
		//get a valid filename
		char *newline;
		do
		{
			printf("Enter the name of the file containing the hard vector:  ");
			ret = fgets(fname, 200, stdin);
		}
		while(ret == NULL);
		
		newline = strchr(fname, '\n');
		
		//if there is a newline replace it with a null terminator
		//if not then the path name filled the buffer
		//more likely than not the path will not be fully contained and the file will
		//not be found.  The buffer should be big enough to hold most paths.
		if(newline != NULL)
		{
			*newline = '\0';
		}
		
		if((fp = fopen((const char *)fname, "r")) != NULL)
		{
			return fp;
		}
	}
}